package com.hn.kiss.config.compoent;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;

@Component
public class Context<T> {
    @Autowired
    ApplicationContext applicationContext;

    public T getInstance(String beanName) {
        T t = null;
        try {
            t = (T) applicationContext.getBean(beanName);
        } catch (BeansException e) {
            e.printStackTrace();
        }
        return t;
    }
}
